﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Peekaboo2008.model;
using System.Data;
using System.Data.SqlClient;
using Peekaboo2008.util;

namespace Peekaboo2008.dao
{
    class NgoaiTeDAO
    {
        public static DataTable getAll()
        {
            return DataUtil.executeStore("sp_NgoaiTe_GetAll", null);
        }
        public static NgoaiTeModel getById(String Id)
        {
            NgoaiTeModel _model = null;
            int i = 0;
            SqlParameter[] param = new SqlParameter[1];
            param[i] = new SqlParameter("ID", SqlDbType.Int);
            param[i++].Value = Id;

            DataTable _dt = DataUtil.executeStore("sp_NgoaiTe_GetById", param);

            try
            {
                foreach (DataRow dr in _dt.Rows)
                {
                    _model = new NgoaiTeModel();
                    _model.ID = dr["ID"].ToString();
                    _model.DonViGoc = dr["Don_vi_goc"].ToString();
                    _model.KiHieu = dr["Ki_hieu"].ToString();
                    _model.TyGia = dr["Ty_gia"].ToString();
                    _model.ChildId = dr["Child_id"].ToString();
                    _model.GhiChu = dr["Ghi_chu"].ToString();
                    _model.NgayCapNhatCuoi = dr["Ngay_cap_nhat_cuoi"].ToString();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace.ToString());
            }
            return _model;
        }
    }
}
